package com.example.test_touch.test

import android.os.Bundle
import android.util.Log
import android.view.MotionEvent
import androidx.activity.enableEdgeToEdge
import androidx.appcompat.app.AppCompatActivity
import androidx.core.view.ViewCompat
import androidx.core.view.WindowInsetsCompat
import com.example.test_touch.R

/**

 1，dispatchTouchEvent分发
    super:继续向下分发
    false:不分发，在此结束消息
    true:不分发，交给上一级onTouchEvent
 2.onInterceptorTouchEvent拦截：注意只有ViewGroup有
    super/false：不拦截，事件继续向下传递
    true：拦截，执行onTouchEVent
 3，onTouchEvent消费
    true：自己消费
    false/super：向上传递

 */
class MainActivity : AppCompatActivity() {
    companion object{
        const val TAG = "MainActivity"
    }
    override fun onCreate(savedInstanceState: Bundle?) {
        super.onCreate(savedInstanceState)
        enableEdgeToEdge()
        setContentView(R.layout.activity_main2)

    }

    override fun dispatchTouchEvent(ev: MotionEvent?): Boolean {
        if (ev?.action == MotionEvent.ACTION_DOWN){
            Log.d(TAG, "dispatchTouchEvent:分发 ")
        }
        return super.dispatchTouchEvent(ev)
    }

    override fun onTouchEvent(event: MotionEvent?): Boolean {
        if (event?.action == MotionEvent.ACTION_DOWN){
            Log.d(TAG, "onTouchEvent: 消费")
        }
        return super.onTouchEvent(event)
    }
}